]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Support setting the image after construction
authorGiovanni Campagna <scampa.giovanni@gmail.com>
Tue, 6 Jul 2010 07:51:53 +0000 (09:51 +0200)
committerDan Winship <danw@gnome.org>
Wed, 15 Sep 2010 17:34:28 +0000 (13:34 -0400)
This patch allows the icon in PopupImageMenuItems to be changed at
any time, while preserving the item and all other properties (style,
signals) attached and without rebuilding the whole menu. This is useful
for images reflecting a dynamic status (e.g. cellular strength
indicator or battery level)

https://bugzilla.gnome.org/show_bug.cgi?id=623652

js/ui/popupMenu.js

index e307d4e2a05c3dec3980a8303d9e280a62d56519..33977e45e5ef33868a10c89ee01f88c5084a4558 100644 (file)
@@ -221,7 +221,8 @@ PopupImageMenuItem.prototype = {
         this.actor.set_child(box);
         this._imageBin = new St.Bin({ width: this._size, height: this._size });
         box.add(this._imageBin, { y_fill: false });
-        box.add(new St.Label({ text: text }), { expand: true });
+        this.label = new St.Label({ text: text });
+        box.add(this.label, { expand: true });
 
         if (!alwaysShowImage) {
             let settings = Gtk.Settings.get_default();
@@ -245,6 +246,11 @@ PopupImageMenuItem.prototype = {
             this._imageBin.set_child(img);
             this._imageBin.show();
         }
+    },
+    
+    setIcon: function(name) {
+        this._iconName = name;
+        this._onMenuImagesChanged();
     }
 };